package fmi.chesstern.interpreter;

import java.util.ArrayList;

public class ParseObject {
	
	private Action action;
	private ArrayList<Object> parameters;
	
	public ParseObject(Action action, ArrayList<Object> params) {
		this.action = action;
		this.parameters = params;
	}
	
	public ParseObject() {
		parameters = new ArrayList<Object>();
	}

	public void addParameter(Object param) {
		parameters.add(param);
	}
	
	public Action getAction() {
		return action;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	public ArrayList<Object> getParameters() {
		return parameters;
	}

	public void setParameters(ArrayList<Object> parameters) {
		this.parameters = parameters;
	}
	
	public enum Action {
		MOVE("move"), FORFEIT("forfeit"), UNDO("undo"), UNKNOWN("unknown");
		
		private String name;
		
		private Action(String name) {
			this.name = name;
		}
		
		public String getName() {
			return name;
		}
		
		public static Action getAction(String name) {
			Action action = Action.UNKNOWN;
			if (name.equals("move")) {
				action = Action.MOVE;
			} else if (name.equals("forfeit")) {
				action = Action.FORFEIT;
			} else if (name.equals("undo")) {
				action = Action.UNDO;
			}
			return action;
		}
		
		public String toString() {
			return getName();
		}
	}
}
